package com.ruoyi.web.controller.tool;

import java.io.FileOutputStream;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;

import com.deepoove.poi.XWPFTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import io.swagger.annotations.Api;
@Api("用户信息管理")
@RestController
@RequestMapping("/test/user")
public class TestController extends BaseController
{
    public static void main(String[] args) {
        String dateStr1 = "20231004"; // 示例日期1
        String dateStr2 = "20231005"; // 示例日期2

        boolean isPreviousDay = isOneDayBefore(dateStr1, dateStr2);
        System.out.println("Is " + dateStr1 + " one day before " + dateStr2 + "? " + isPreviousDay);
    }

    public static boolean isOneDayBefore(String dateStr1, String dateStr2) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");

        try {
            LocalDate date1 = LocalDate.parse(dateStr1, formatter);
            LocalDate date2 = LocalDate.parse(dateStr2, formatter);

            return ChronoUnit.DAYS.between(date1, date2) == 1;
        } catch (Exception e) {
            // 处理解析错误，例如日期格式不正确
            e.printStackTrace();
            return false;
        }
    }
}
